package cn.sangedon.review.analysis.controller;

import cn.sangedon.review.analysis.domain.StrategyResultQuery;
import cn.sangedon.review.analysis.service.StockStrategyResultService;
import cn.sangedon.review.common.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "交易策略结果")
@RestController
@RequestMapping("strategy_result")
public class StrategyResultController {
    @Autowired
    private StockStrategyResultService stockStrategyResultService;

    /**
     * 获取策略结果
     *
     * @return
     */
    @ApiOperation("获取策略结果")
    @PostMapping("list")
    public Result getStrategyResult(@RequestBody StrategyResultQuery strategyResultQuery) {
        return Result.okBuilder().data(stockStrategyResultService.getStrategyResult(strategyResultQuery)).build();
    }

    /**
     * 验证最近交易策略推荐股票的涨跌结果
     *
     * @param startTime
     * @param endTime
     * @return
     */
    @ApiOperation("验证最近交易策略推荐股票的涨跌结果")
    @GetMapping("verify")
    public Result verifyLatest(String startTime, String endTime) {
        stockStrategyResultService.verify();
        return Result.ok();
    }

    @ApiOperation("验证最近策略结果第二天行情信息")
    @GetMapping("verify/latest/strategy/result")
    public Result verifyLatestStrategyResult() {
        stockStrategyResultService.stockStrategyResultService();
        return Result.ok();
    }

    /**
     * 获取策略结果
     *
     * @param tradeDate 交易日起
     * @return
     */
    @ApiOperation("获取下跌缩量红策略结果")
    @GetMapping("listFallShrinkResult")
    public Result listFallShrinkResult(String tradeDate) {
        return Result.okBuilder().data(stockStrategyResultService.listFallShrinkResult(tradeDate)).build();
    }

    @ApiOperation("验证历史策略结果第二天行情信息")
    @GetMapping("verify/history/strategy/result")
    public Result verifyHistoryStrategyResult(String tradeDate) {
        stockStrategyResultService.verifyHistoryStrategyResult(tradeDate);
        return Result.ok();
    }

    @ApiOperation("运算某个交易日符合下跌缩量红策略结果")
    @GetMapping("execute/fall/shrink/red/result")
    public Result executeFallShrinkRedResult(String tradeDate) {
        stockStrategyResultService.executeFallShrinkRedResult(tradeDate);
        return Result.ok();
    }

    @ApiOperation("运算某个交易日符合上涨缩量红策略结果")
    @GetMapping("execute/rise/shrink/red/result")
    public Result executeRiseShrinkRedResult(String tradeDate) {
        stockStrategyResultService.executeRiseShrinkRedResult(tradeDate);
        return Result.ok();
    }

    @ApiOperation("运算多个交易日符合上涨缩量红策略结果")
    @GetMapping("rise/shrink/red/result")
    public Result executeRiseShrinkRedResult() {
        String[] tradeDates = new String[] {

        };
        for (String tradeDate : tradeDates) {
            stockStrategyResultService.executeRiseShrinkRedResult(tradeDate);
        }
        return Result.ok();
    }

    @ApiOperation("验证某个策略次日涨行情")
    @GetMapping("verify/strategy/result")
    public Result verifyStrategyResult(Long strategyId) {
        String[] tradeDates = new String[] {

        };
        for (String tradeDate : tradeDates) {
            stockStrategyResultService.verifyStrategyResult(strategyId, tradeDate);
        }
        return Result.ok();
    }

    /**
     * 缩量红股票后三日股票涨跌情况
     *
     * @return
     */
    @ApiOperation("缩量红股票后三日股票涨跌情况")
    @GetMapping("strategy/verify")
    public Result verifyStrategy() {
        return Result.okBuilder().data(stockStrategyResultService.verifyStrategy()).build();
    }
}
